package com.df.my_net_game.common.server;

import com.df.my_net_game.net.base.IMsgInterceptor;
import com.df.my_net_game.net.base.EZGameCtx;
import io.netty.channel.Channel;
import io.netty.util.AttributeKey;

public class MyMsgInterceptor implements IMsgInterceptor {
    public static AttributeKey<Integer> playerId = AttributeKey.newInstance("playerId");
    @Override
    public void beforeInvoke(EZGameCtx context) {
        Channel channel = context.getChannel();
        Integer playerId = channel.attr(MyMsgInterceptor.playerId).get();
        if (playerId != null) {
            context.put("playerId", playerId);
        }
    }

    @Override
    public void afterInvoke(EZGameCtx context) {

    }

    @Override
    public void onException(Exception e, EZGameCtx context) {

    }
}
